package crm.dao.impl;

import crm.Utils.JDBCUtil;
import crm.dao.AdminDao;
import crm.entity.Admin;

import java.util.ArrayList;
import java.util.HashMap;

public class AdminServerImpl extends JDBCUtil implements AdminDao {


//    注册管理员  账号密码
    @Override
    public int add(Admin admin) {
        String sql = "insert into admin(name,password) values(?,?);";
        Object[] params = {admin.getName(),admin.getPassword()};
        int i = this.executeUpdate(sql, params);
        return i;
    }

// 查询管理员
    @Override
    public boolean findAdmin(Admin admin) {
        Boolean flag = false;
        ArrayList<HashMap> list = new ArrayList<>();

        String sql = "select * from admin where name=? and password=?";
        Object[] params = {admin.getName(), admin.getPassword()};

        list = this.executeQuery(sql, params);
        if (list.size() > 0) {
            flag = true;
        }
        return flag;
    }
}
